<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ page import="com.ai.core.util.Configure"%>
<%@ page import="com.ai.wx.util.WeixinUtil"%>
<%@ page import="com.ai.wx.entity.AgentUser"%>
<%@ page import="com.ai.core.constant.GlobalConstant"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>推广金提取审核</title>
<link media="all" href="${ctx}/css/box.css" rel="stylesheet">
<link media="all" href="${ctx}/css/style.css" rel="stylesheet">

<script type="text/javascript" src="${ctx}/js/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/js/common.js"></script>
<script src="${ctx}/js/handlebars-v2.0.0.js"></script>


</head>
<body>
<div class="wrap">
  <div class="head">
    <div>| 流量超市后台管理系统</div>
  </div>
  <div class="out-content">
    <div class="user">
      <div class="user-text">
        <p>下午好，管理员</p>
        <p><span>账户名 : admin</span><span>上次登录时间 ： 2015-05-14</span></p>
      </div> 
    </div>
    <div class="ui-nav ui-nav-nosub">
      <ul class="ui-nav-main">
        <li class="ui-nav-item "> <a href="${ctx}/ht/agentUserApprove">推广员审核</a> </li>
        <li class="ui-nav-item ui-nav-item-current"> <a href="${ctx}/ht/brokerageDrawApprove">推广金提取审核</a> </li>
      </ul>
      <div class="ui-nav-subcontainer"></div>
    </div>
    <div class="ui-table-container">
      <table class="ui-table recharge">
        <!-- 可以在class中加入ui-table-inbox或ui-table-noborder分别适应不同的情况 -->
        <thead>
          <tr>
            <th width="120px">日期</th>
            <th width="100px">姓名</th>
            <th width="100px">提取金额</th> 
            <th width="60px">状态</th> 
            <th>回复</th> 
            <th width="80px">详情</th>
          </tr>
        </thead>
        <!-- 表头可选 -->
        <tbody id="tableData"> 
        </tbody>
        <tfoot>
          <tr>
            <td colspan="6"  id="paging">
               
            </td>
          </tr>
        </tfoot>
        <!-- 表尾可选 -->
      </table>
    </div>
  </div>
</div>
<div class="foot">
  <p></p>
</div>

<!-- 弹窗 -->
<div id="open-window"></div>
<!-- 点击日志图片放大 -->
<div style="overflow:auto;position: fixed;  top: 0px; left: 0px; background: none repeat scroll 0% 0% rgba(0, 0, 0, 0.7); z-index:999999; width: 100%; height: 100%; display: none;" id="outerdiv">
    <div style="position: absolute; top: 63.1px; left: 270.66px;" id="innerdiv">
       <img src="" style="border: 5px solid rgb(255, 255, 255); width: 807.68px;" id="bigimg">
    </div>
</div>

<script id="drawList" type="text/x-handlebars-template">
   {{#each this}}
          <tr {{trClass @index}}>
            <td>{{drawDate}}</td>
            <td>{{userName}}</td>
            <td style="color:#f37800">{{dDrawCharge}}</td>
             <td style="color:#f37800">{{drawStateStr drawState}}</td>
            <td>{{reply}}</td>
            <td><a href="javascript:;" class="ui-button ui-button-swhite" onClick="openWin({{id}})">审核</a></td>
          </tr> 
   {{/each}}
</script>

<script id="drawInfoWin" type="text/x-handlebars-template">
   {{#each this}}  
  <div id="overlay"></div>
  <div id="dialog">
    <div class="dialog-body">
      <div class="ui-box window">
        <div class="ui-box-head">
          <h3 class="ui-box-head-title">推广金提取审批</h3>
          <a href="#" class="ui-box-head-more" onClick="closeWin()"><em>×</em></a> </div>
        <div class="ui-box-container">
          <div class="ui-box-content">
            <dl class="ui-dlist">
              <dt class="ui-dlist-tit">姓名：</dt>
              <dd class="ui-dlist-det">{{userName}}</dd>
              <dt class="ui-dlist-tit">提取金额：</dt>
              <dd class="ui-dlist-det"  style="color:#f37800">{{drawCharge}}</dd>
              <dt class="ui-dlist-tit">身份证号码：</dt>
              <dd class="ui-dlist-det">{{idCard}}</dd>
             <dt class="ui-dlist-tit">手机号码：</dt>
              <dd class="ui-dlist-det">{{phone}}</dd>
              <dt class="ui-dlist-tit">开户银行：</dt>
              <dd class="ui-dlist-det">{{bankName}}</dd>
              <dt class="ui-dlist-tit">银行卡号</dt>
              <dd class="ui-dlist-det">{{bankCard}}</dd>
              <dt class="ui-dlist-tit">日期：</dt>
              <dd class="ui-dlist-det">{{drawDate}}</dd>
              <dt class="ui-dlist-tit">状态：</dt>
              <dd class="ui-dlist-det">{{drawStateStr drawState}}</dd>

              <dt class="ui-dlist-tit">审批回复：</dt>
              <dd class="ui-dlist-det"><textarea name="reply" id="reply"></textarea></dd>
            </dl>
          </div>
          <a href="javascript:;" class="ui-button ui-button-lorange" onclick="brokerageDrawApprove({{id}})">通过</a> <a href="javascript:;" class="ui-button ui-button-lwhite" onclick="brokerageDrawRefuse({{id}})">拒绝</a> </div>
      </div>
    </div>
  </div> 
   {{/each}}
</script>
<script type="text/javascript">

var page = 1,rows=20,totalPage;
Handlebars.registerHelper('trClass',function(index,options){
    if(index%2==0){
        return 'class="ui-table-split"';
    }else{
        return '';
    }
});
Handlebars.registerHelper('drawStateStr',function(drawState,options){
    if(drawState==0){
        return '审核中';
    }
    if(drawState==1){
        return '审核通过';
    }
    if(drawState==-1){
        return '审核不通过';
    }
});
$(function() {
    show(1);
});
var tableData=Handlebars.compile($('#drawList').html());
function show(pageNo){
    page=pageNo;
    var drawState = null; 
    $.ajax({ 
        url: '${ctx}/ht/getBrokerageDrawList',
        type: 'POST',
        data: {drawState:drawState,page:page,rows:rows},
        cache:false,
        dataType:'json',  
        success: function(data){ 
            $('#tableData').html(tableData(data.rows));
            $('#paging').html(pageFoot(page,data.total,20));
         },
        error : function(data) {    
            alert(data);
        }    
    });
}


var drawInfoWin=Handlebars.compile($('#drawInfoWin').html());
function openWin(id){
       $.ajax({ 
            url: '${ctx}/ht/getBrokerageDrawList',
            type: 'POST',
            data: {id:id,page:1,rows:1},
            cache:false,
            dataType:'json',  
            success: function(data){ 
                $('#open-window').html(drawInfoWin(data.rows)); 
             },
            error : function(data) {    
                alert(data);
            }    
        });
    
}
function closeWin(){
      $('#open-window').html(''); 
}

function brokerageDrawApprove(id){
    var reply=$('#reply').val();
    if(reply.length == 0){
        alert('请输入审核回复');
        return;
    }
    $.ajax({ 
        url: '${ctx}/ht/approveDrawBrokerage',
        type: 'POST',
        data: {id:id,drawState:1,reply:reply},
        cache:false,
        dataType:'json',  
        success: function(data){
            if(data.success){
                $('#open-window').html(''); 
                show(page);
            }else{
                alert('提交失败，错误原因:'+data.msg);
            }
         },
        error : function(data) {    
            alert(data);
        }    
    });
}
function brokerageDrawRefuse(id){
    var reply=$('#reply').val();
    if(reply.length == 0){
        alert('请输入审核回复');
        return;
    }
    $.ajax({ 
        url: '${ctx}/ht/refuseDrawBrokerage',
        type: 'POST',
        data: {id:id,drawState:-1,reply:reply},
        cache:false,
        dataType:'json',  
        success: function(data){
            if(data.success){
                $('#open-window').html(''); 
                show(page);
            }else{
                alert('提交失败，错误原因:'+data.msg);
            }
         },
        error : function(data) {    
            alert(data);
        }    
    });
}
</script>




</body>
</html>
